<script type="text/javascript" charset="utf-8">
  function showSlideshow() {
    images = [
    <% for photo in @entry.photos %>
      "<%= "http://#{request.domain}:#{request.port.to_s}#{photo.relative_url}" %>"
      <% if photo != @entry.photos.last %> , <% end %>
    <% end %>
    ];

    titles = [
    <% for photo in @entry.photos %>
      "<%=h photo.title %>"
      <% if photo != @entry.photos.last %> , <% end %>
    <% end %>
    ];

    descriptions = [
    <% for photo in @entry.photos %>
      "<%=h photo.description %>"
      <% if photo != @entry.photos.last %> , <% end %>
    <% end %>
    ];

    $.prettyPhoto.open(images, titles, descriptions);
  };

  $(document).ready(function(){
    $("a[rel^='prettyPhoto']").prettyPhoto({slideshow:4000,
      theme:'dark_rounded',
      autoplay_slideshow: true});
  });
</script>

<div id="content">
  <div id="entry_info">
    <h2 id="entry_title"><%=h @entry.title %></h2>
    <p id="entry_desc"><%=h @entry.description %></p>
    <p id="entry_author">
      Posted by:
      <span><%=h @entry.content_generator.username %></span>
    </p>
  </div>
  <% if current_user == @entry.content_generator %>
  <div id="entry_control">
    <%= link_to 'Edit Entry', edit_entry_path(@entry) %> |
    <%= link_to 'Manage Comments', entry_comments_path(@entry) %> 
  </div>
  <% end %>
  <div id="show_slideshow">
    <a href="#" onclick="javascript:showSlideshow()">play slideshow</a>
  </div>

  <div id="photo_index">
    <ul>
    <% for photo in @entry.photos %>
      <li>
      <a href="<%= photo_path(photo) %>">
        <img class="thumbnail" alt="<%= photo.title %>" src="<%= "http://#{request.domain}:#{request.port.to_s}#{photo.thumbnail_relative_url}" %>" /></a>
      </li>
    <% end %>
    </ul>
  </div>
  <div id="comments">
    <h3>Comments</h3>
    <% if @entry.comments.size > 0 %>
      <ul>
      <% @entry.comments.each do |c| %>
        <li>
          <p><span class="comment_cg">
            <%=h c.content_generator.username %></span>: 
          <span class="comment_content"><%=h c.content %></span></p>
        </li>
      <% end %>
      </ul>
    <% end %>
    <p id="add_comment">
      <%= link_to 'Add Comment', new_entry_comment_path(@entry) %></p>
  </div>
</div>
